<script>
    $(document).ready(function () {
        $( "input:submit").button();
    });
</script>

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'transaction-form',
	'enableAjaxValidation'=>true,
)); ?>

	<p class="note"><?php  echo Yii::t('application', 'Fields with <span class="required">*</span> are required.');?></p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row"> <!--transactionmastervoucherdate -->
                		<?php echo $form->labelEx($model,'transactionmastervoucherdate'); ?>            
		<?php echo $form->textField($model,'transactionmastervoucherdate'); ?>
		<?php echo $form->error($model,'transactionmastervoucherdate'); ?>
	</div>
        
	<div class="row"> <!--transactionmasternarration -->
                		<?php echo $form->labelEx($model,'transactionmasternarration'); ?>            
		<?php echo $form->textField($model,'transactionmasternarration',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'transactionmasternarration'); ?>
	</div>
        
	<div class="row"> <!--idvouchertype -->
                                <?php echo $form->labelEx($model,'yii_vouchertype'); ?>
                <?php
                $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                    'model' => $model, 
                    'id' => 'Transaction_yii_vouchertype',
                    'name' => 'yii_vouchertype',
                    'value'=>$model->idvouchertype0!=NULL ? $model->idvouchertype0->yii_vouchertype : '', 
                    'theme' => 'bgscstpc',
                    'source' => $this->createUrl('vouchertype/autocomplete'),
                    // additional javascript options for the autocomplete plugin
                    'options' => array(
                        'showAnim' => 'fold',
                    ),
                    'htmlOptions' => array(
                    )
                ));
                ?>
                <?php
                    $imghtml = CHtml::image(Yii::app()->request->baseUrl . '/images/tooltip.png');
                    echo CHtml::ajaxLink(
                            $imghtml, 
                            array('vouchertype/popupview'), // the URL for the AJAX request. If empty, it is assumed to be the current URL.
                            array(
                                "data" => array(
                                    "isAjaxRequest" => 1,
                                ),
                                'success' => 'function(data){
                                        window.cid = "transaction";
                                        window.autocomplete = "Transaction_yii_vouchertype";
                                        $("#dialog-popup-select").html(data);
                                        $("#dialog-popup-select").dialog("option", "title", "'. Yii::t('application', 'Vouchertypes') .'");
                                        $("#dialog-popup-select").dialog("open"); 
           
                                        return false;
                                    }'
                    ) 
                    );
                    ?>
		<?php echo $form->error($model,'yii_vouchertype'); ?>
	</div>
        
	<div class="row"> <!--transactiondetails -->
                		<?php echo $form->labelEx($model,'transactiondetails'); ?>            
		<?php echo $form->textArea($model,'transactiondetails',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'transactiondetails'); ?>
	</div>
        
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('application', 'Create') : Yii::t('application', 'Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<?php
$this->widget('ext.ajaxform.JAjaxForm', array(
    'formId' => 'transaction-form',
    'options' => array(
        'dataType' => 'json',
        'success' => 'js:function(data,statusText) { 
                    if(data.status == "Success"){
                        $.fn.yiiGridView.update("transaction-grid", {
                              data: $(this).serialize()
                        });
                        $("#dialog").dialog("close").destroy();
                        return false;
                    }
                    else{
                        $("#dialog-warning-msg").html("' . Yii::t('application', 'An error occurred while the form was being submitted.<br/>Please check your form data.') . '" + data.status); 
                        $("#dialog-warning").dialog("open"); 
                        return false;
                    }
        }',
    ),
));
?>
